@using System.Web.Http
@using System.Web.Http.Description
@using WebFoundation.WebServer.Areas.HelpPage.Models
@using WebFoundation.WebServer.Areas.HelpPage.ModelDescriptions
@using WebFoundation.WebServer.Areas.HelpPage
@model HelpPageApiModel

@{
    /**/

    ApiDescription description = Model.ApiDescription;
    bool nonParamter = Model.UriParameters == null || Model.UriParameters.Count == 0;
    nonParamter = nonParamter && (Model.RequestBodyParameters == null || Model.RequestBodyParameters.Count == 0);
    nonParamter = nonParamter && (Model.RequestModelDescription == null);
    bool noResult = true;
    if (Model.ResourceDescription != null)
    {
        noResult = false;
    }
    var path = description.RelativePath;
    if (description.RelativePath.IndexOf('?') > 0)
    {
        path = description.RelativePath.Substring(0, description.RelativePath.IndexOf('?'));
    }

    path = path.TrimEnd('/');

    var indexOfBackslash = path.IndexOf("/");

    var prefix = string.Empty;
    prefix = path.Substring(indexOfBackslash + 1);

    var actionName = path.Substring(path.LastIndexOf('/') + 1);

    prefix = prefix.Substring(0, prefix.Length - actionName.Length - 1);

}

/** @description.HttpMethod.Method @description.RelativePath */
@*@if (!description.Documentation.IsEmpty())
{
    @: * [Description]: @description.Documentation
}
@if (!nonParamter)
{

    <text>
         * [Parameters]:
        @if (Model.UriParameters != null && Model.UriParameters.Count > 0)
        {
            @: * Type: @string.Join("", description.ActionDescriptor.ControllerDescriptor.ControllerName + "Module", description.ActionDescriptor.ActionName)Parameters
        }
        else
        {
            @: * Type: @Model.RequestModelDescription.GetTypeName()
        }
        @if (Model.SampleRequests.Count > 0)
        {
            @: * @Html.DisplayFor(m => m.SampleRequests, "Samples")
        }
    </text>
}
@if (!noResult)
{
    <text>
        [Callback Data]:
        @description.ResponseDescription.Documentation
        @if (Model.ResourceDescription != null)
        {
            @:* Type: @Model.ResourceDescription.GetTypeName()
        }
        @if (Model.SampleResponses.Count > 0)
        {
            @:* @Html.DisplayFor(m => m.SampleResponses, "Samples")
        }
    </text>
}
*/*@
public @actionName (
@if (!nonParamter)
{
    if (Model.UriParameters != null && Model.UriParameters.Count > 0)
    {
        @:parameters: @string.Join("", description.ActionDescriptor.ControllerDescriptor.ControllerName + "Module", description.ActionDescriptor.ActionName)Parameters,
    }
    else
    {
        @:parameters: @Model.RequestModelDescription.GetTypeName(),
    }
}
    showProgress: boolean = true,
    ){

    return this.app.request.@(description.HttpMethod.Method.ToLower())<@(noResult ? "any" : Model.ResourceDescription.GetTypeName())>
        ('@prefix', '@actionName', @(!nonParamter ? "parameters" : "null"), {notShowProgress: !showProgress});
        }

